const BaseService = require("./BaseService.js");
const AppConfig = require("../config/AppConfig.js");
const PageList = require("../model/PageList.js")

class StuInfoService extends BaseService {
    constructor(){
        super();
        this.currentTableName = this.tableMap.stu_info;
    }
    async getList({sname,pageIndex}){
        console.log(sname,pageIndex);
        
        let strSql = `select * from ${this.currentTableName} where 1 and isDel = false`;
        let countSql = `select count(*) 'total_count' from ${this.currentTableName} where 1 and isDel = false`;
        let strWhere = ``;
        let ps = [];
        if(sname){
            strWhere += ` and sname like ?`;
            ps.push(`%${sname}%`)
        }
        strSql += ` ${strWhere} limit ${(pageIndex - 1) * this.pageSize},${this.pageSize}`;
        countSql += strWhere;
        let results = await this.excuteSql(strSql + ";" + countSql,[...ps,...ps]);
        let pageList = new PageList(pageIndex,results[1][0].total_count,results[0],this.pageSize)
        return pageList;
    }
}
module.exports = StuInfoService









